Skip to content

Use explicit Anthropic computer tools - #16

Merged
rgarcia merged 2 commits into
mainfrom
hypeship/anthropic-explicit-tools
Jun 3, 2026
Merged

Use explicit Anthropic computer tools#16
rgarcia merged 2 commits into
mainfrom
hypeship/anthropic-explicit-tools

Conversation

@rgarcia

@rgarcia rgarcia commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related changes to @onkernel/cua-ai (and its @onkernel/cua-agent consumer):

1. Explicit Anthropic computer tools

  • Add an Anthropic-specific computer tool module backed by the latest computer-use best-practices quickstart, exposing an explicit canonical Anthropic CUA tool set instead of re-exporting the global default.
  • Include the canonical computer_batch tool by default for Anthropic, with excludeBatch for individual-only tool definitions.
  • Move batch inclusion out of CuaAgent/CuaAgentHarness options so providers decide whether batch is part of their runtime defaults.

2. CuaProviderModule contract + registry refactor

  • Replace the per-provider switch in resolveCuaRuntimeSpec with a registry lookup over provider modules that conform to a shared CuaProviderModule interface. Adding a provider is now "write the module, add one line"; satisfies Record<CuaProvider, CuaProviderModule> makes a missing or non-conforming provider a compile error.
  • Move the provider-contract types (CuaPayloadHook, CuaScreenshotSpec, CuaRuntimeSpec, etc.) into providers/common.ts so common.ts owns the contract and runtime-spec.ts only composes it. This also removes the provider → runtime-spec back-import (a layering inversion).
  • Each provider now exposes coordinateSystem() as a function instead of the constant-like COMPUTER_TOOL_COORDINATES field.
  • Standardize on build<Provider>SystemPrompt() across all providers; add the previously-missing buildOpenAISystemPrompt().
  • Drop the dead yutoriBuiltinToolsOnPayload alias; yutoriNativeToolSetOnPayload is the single canonical name.
  • Preserve Yutori's model-facing toolDefinitions: [] invariant in its module.
  • Add provider-module.test.ts asserting every provider conforms to the contract; update the README to match.

User-facing API changes (@onkernel/cua-ai)

  • <provider>.COMPUTER_TOOL_COORDINATES<provider>.coordinateSystem()
  • Added <provider>.build<Provider>SystemPrompt() for every provider (incl. buildOpenAISystemPrompt)
  • Removed yutori.yutoriBuiltinToolsOnPayload → use yutori.yutoriNativeToolSetOnPayload
  • Added providerModule export per provider and the CuaProviderModule type

Tests

  • npx tsc -b (whole monorepo): green
  • npm test --workspace @onkernel/cua-ai: 56 passing, 5 skipped (live-only)
  • Live provider integration (computer-tool.integration.test.ts): openai, anthropic, google, tzafon pass; yutori untested due to an ongoing upstream n1 API partial outage (per yutori.statuspage.io), reproduced outside this code via raw HTTP — not a regression.

@rgarcia
rgarcia force-pushed the hypeship/anthropic-explicit-tools branch from ff4e3e6 to 4383ea5 Compare May 20, 2026 19:27
@rgarcia
rgarcia marked this pull request as ready for review May 21, 2026 13:44
@firetiger-agent

Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: PR modifies AI/computer-use tool modules (@onkernel/cua-ai, @onkernel/cua-agent) rather than kernel API endpoints or Temporal workflows.

To monitor this PR anyway, reply with @firetiger monitor this.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Exported createActionSchema function lacks TSDoc
    • Added a TSDoc block to createActionSchema describing Anthropic compatibility and its unsupported-action validation behavior.

Create PR

Or push these changes by commenting:

@cursor push 07eace1ec7
Preview (07eace1ec7)
diff --git a/packages/ai/src/providers/anthropic/actions.ts b/packages/ai/src/providers/anthropic/actions.ts
--- a/packages/ai/src/providers/anthropic/actions.ts
+++ b/packages/ai/src/providers/anthropic/actions.ts
@@ -37,6 +37,12 @@
 	return resolved;
 }
 
+/**
+ * Build an Anthropic-compatible action schema for CUA browser actions.
+ *
+ * Pass `actions` to expose only a supported subset. Unsupported actions are
+ * rejected so callers get early validation before tool invocation.
+ */
 export function createActionSchema(actions?: readonly CuaActionType[]) {
 	return createCuaActionSchema(resolveAnthropicActions(actions));
 }

You can send follow-ups to the cloud agent here.

Comment thread packages/ai/src/providers/anthropic/actions.ts
@rgarcia
rgarcia force-pushed the hypeship/anthropic-explicit-tools branch 2 times, most recently from e517a08 to b5f3102 Compare May 21, 2026 15:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Reviewed by Cursor Bugbot for commit b5f3102. Configure here.

Comment thread packages/ai/src/providers/anthropic/actions.ts Outdated
@rgarcia
rgarcia force-pushed the hypeship/anthropic-explicit-tools branch 2 times, most recently from 06ac4ab to 51a3bdf Compare May 21, 2026 16:20
@rgarcia
rgarcia force-pushed the hypeship/anthropic-explicit-tools branch from 51a3bdf to c8849b2 Compare May 21, 2026 18:08
Replace the per-provider switch in resolveCuaRuntimeSpec with a registry
lookup over provider modules that conform to a shared CuaProviderModule
interface. Adding a provider is now "write the module, add one line"; the
`satisfies Record<CuaProvider, CuaProviderModule>` makes an unconformed or
missing provider a compile error.

- Define CuaProviderModule in providers/common.ts and move the provider
  contract types (CuaPayloadHook, CuaScreenshotSpec, CuaRuntimeSpec, etc.)
  there so common.ts owns the contract and runtime-spec.ts only composes it.
- Expose coordinateSystem() as a function on each provider instead of the
  constant-like COMPUTER_TOOL_COORDINATES field.
- Standardize on build<Provider>SystemPrompt() everywhere; add the missing
  buildOpenAISystemPrompt().
- Drop the dead yutoriBuiltinToolsOnPayload alias; yutoriNativeToolSetOnPayload
  is the single canonical name. Fix yutori/provider.ts to import the payload
  context type from ../common instead of back-importing runtime-spec.
- Preserve Yutori's model-facing toolDefinitions: [] invariant in its module.
- Add provider-module.test.ts asserting every provider conforms to the
  contract; update README to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rgarcia
rgarcia merged commit d3beac2 into main Jun 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant